import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import type {AxiosRequestConfig} from "axios";
import {defHttp} from "@/utils/http/axios";

export interface OAuth2ClientVO {
  id: number
  clientId: string
  secret: string
  name: string
  logo: string
  description: string
  status: number
  accessTokenValiditySeconds: number
  refreshTokenValiditySeconds: number
  redirectUris: string[]
  autoApprove: boolean
  authorizedGrantTypes: string[]
  scopes: string[]
  authorities: string[]
  resourceIds: string[]
  additionalInformation: string
  isAdditionalInformationJson: boolean
  createTime: Date
}

const MODULAR = '/system/oauth2-client';

export const Api ={
  GetOAuth2ClientPage:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetOAuth2Client:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateOAuth2Client:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateOAuth2Client:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteOAuth2Client:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig
}

// 查询 OAuth2 客户端的列表
export const getOAuth2ClientPage = (params) => {
  return defHttp.request({ ...Api.GetOAuth2ClientPage,params})
}

// 查询 OAuth2 客户端的详情
export const getOAuth2Client = (id) => {
  let params = {id:id}
  return defHttp.request({ ...Api.GetOAuth2Client,params})
}

// 新增 OAuth2 客户端
export const createOAuth2Client = (data) => {
  return defHttp.request({ ...Api.CreateOAuth2Client,params:data})
}

// 修改 OAuth2 客户端
export const updateOAuth2Client = (data) => {
  return defHttp.request({ ...Api.UpdateOAuth2Client,params:data})
}

// 删除 OAuth2
export const deleteOAuth2Client = (id) => {
  let params = {id:id}
  return defHttp.request({ ...Api.DeleteOAuth2Client,params})
}
